Skip to content

fix(desktop): recover Pi after offline startup (#3382) - #3394

Merged
MagicLizi merged 19 commits into
makecindy:mainfrom
qsoyq:fix-issue-3382-pi-network-recovery
Aug 28, 2026
Merged

fix(desktop): recover Pi after offline startup (#3382)#3394
MagicLizi merged 19 commits into
makecindy:mainfrom
qsoyq:fix-issue-3382-pi-network-recovery

Conversation

@qsoyq

@qsoyq qsoyq commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

修复 Cindy 断网启动时 Pi runtime manifest 获取失败后,在网络恢复时无法回到当前进程的问题。Pi 仍然是可选 Agent,不会阻塞 Claude Code、Codex 或主界面启动;恢复时重新走现有 managed prepare/CDN 校验流程,成功后增量注册到现有 Maker。

变更类型

  • fix 缺陷修复
  • feat 新功能
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:[Bug] 断网启动后 Pi 不会在网络恢复时重新出现,需重启才能回来 #3382
  • 本 PR 包含:Pi runtime recovery 状态机、Maker 幂等动态 Agent 注册、Agent roster changed 推送、renderer 可用 Agent 缓存刷新和回归测试。
  • 明确不包含:不改变 Pi 离线复用旧 .verified runtime 的既有策略;不重建 Maker;不改变登录页 Retry 行为。
  • 用户可见变化:网络恢复后,Pi 会在无需重启 Cindy 的情况下重新出现在 Agent 选择器中。
  • 是否存在 breaking change:无

远程与多端适配结论

  • SSH:本 PR 仅恢复本地 Desktop 的 Pi runtime;SSH 远程 Pi 使用独立的远端安装、探测和 daemon 生命周期,本次不改变其行为。
  • device-link:已适配。maker:agents:changed 已加入 push allowlist 和账号级 topic 路由,Desktop 远程控制端可以刷新被控端 Agent roster。
  • Mobile:已适配。Mobile 新建任务页订阅该 roster 变化,并重新读取 maker:list-available-agents;无新增视觉 UI,仅更新运行时列表。

UI 变化

  • 不涉及:仅增加 Agent 列表状态推送和数据刷新,不改变布局、视觉样式或产品文案。
  • 引用的设计规范:不涉及视觉变化。
  • 界面效果证据:不适用(无视觉变化)。本 PR 仅更新已有 Agent 选择器的数据刷新、能力缓存与远程 roster 同步逻辑,没有新增或修改布局、样式、组件结构或产品文案。Pi 恢复后仍复用现有 Agent 选择器展示,因此不附截图、录屏或 HTML 页面。

怎么验证的

自动验证

pnpm --filter desktop typecheck
结果:通过

pnpm --filter desktop exec vitest run src/main/agent-binaries/__tests__/pi-runtime-recovery.test.ts src/main/maker-host/__tests__/piBinaryDistribution.test.ts
结果:7/7 通过

pnpm --filter @cindy/maker-core exec vitest run src/maker.test.ts
结果:78/78 通过

pnpm --filter desktop exec vitest run src/renderer/__tests__/newMakerProjectPicker.test.ts
结果:89/89 通过

pnpm test:unit:related
结果:通过;apps/desktop、packages/lizi-mcps、packages/maker-core、packages/orca-workflow 均通过

pnpm check:dco
结果:通过;1 个 commit 已签署 DCO

手工验证

未完成真实断网/恢复网络的手工验证。当前 Desktop dev 启动会优先使用本地 apps/pi-bin,且没有可强制跳过 dev fallback、改走 runtime CDN 的启动参数;因此 pnpm restart:desktop:remote 无法可靠模拟 Issue 中的 CDN manifest 失败路径。

未执行的验证

未执行 /cindy-dev-cdp-explorer 的真实 CDN 断网/恢复测试,也未执行跨平台打包 smoke。该场景需要在后续 beta packaged 包中验证:断网启动时 Pi 不显示,网络恢复后当前进程重新 prepare、注册并刷新 Agent 选择器。

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest 校验 / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:网络恢复与可选 runtime 生命周期

影响与回滚

  • 影响范围:仅影响 Pi 未注册且启动准备失败的 Desktop 进程;Claude Code、Codex、已有会话和 Maker 生命周期不受影响。恢复仍必须通过当前渠道 manifest、下载和校验。
  • 回滚 / 降级方式:回滚本 PR commit 后,行为恢复为 Pi 只在启动阶段准备,网络恢复需要重启才能重新显示。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

Signed-off-by: qsoyq <github@19940731.xyz>
@qsoyq
qsoyq marked this pull request as ready for review August 25, 2026 09:47
@qsoyq
qsoyq requested a review from a team as a code owner August 25, 2026 09:47
@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 为 Desktop 增加 Pi runtime 的后台恢复能力,使离线启动后无需重启即可重新注册 Pi,并同步刷新本地及远程设备上的 Agent 列表。

  • 新增可取消、可去重且区分暂态与永久错误的 Pi runtime 恢复状态机
  • 支持在现有 Maker 实例中幂等动态注册 Pi,并向 renderer 和 device-link 控制端推送 roster 变化
  • Desktop 与 Mobile 在收到变化事件后刷新 Agent roster 及 capability 缓存
  • 补充恢复状态机、动态注册、远程 topic 路由和界面状态刷新的回归测试

Confidence Score: 5/5

当前 HEAD 未发现仍需在合并前修复的阻塞性故障,看来可以安全合并。

未发现仍然存在的阻塞性故障。

Important Files Changed

Filename Overview
apps/desktop/src/main/agent-binaries/pi-runtime-recovery.ts 新增 Pi 可选 runtime 的单飞重试状态机,并在永久错误或应用退出时停止后续重试。
apps/desktop/src/main/bootstrap-electron.ts 将启动阶段 Pi prepare 失败接入后台恢复,同时保持失败不阻塞 Desktop 启动。
apps/desktop/src/main/maker-host/index.ts 为现有 Maker 增加幂等 Pi 动态注册,并向本地窗口及远程控制端广播 roster 变化。
packages/maker-core/src/maker.ts 增加仅追加且受 shutdown 状态保护的运行时 Agent 注册接口。
apps/desktop/src/renderer/hooks/useAvailableAgents.ts 订阅 roster 变化并失效 Agent 与 capability 缓存,使恢复后的 Pi 立即出现在选择器中。
apps/mobile/app/sessions/new.tsx 持有 sessions topic 订阅并在 roster push 后重新读取远程 Agent 列表,同时取消已失效的重连尝试。
apps/mobile/src/device-link/DeviceLinkContext.tsx 将远程 Agent roster push 路由为设备级回调供 Mobile 页面刷新。
packages/device-link/src/topics.ts 将 Agent roster 变化归入设备级 sessions topic,确保控制端可接收推送。

Reviews (10): Last reviewed commit: "fix(mobile): cancel stale roster resubsc..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d24b5c947

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-host/index.ts
Comment thread apps/desktop/src/main/agent-binaries/pi-runtime-recovery.ts
Signed-off-by: qsoyq <github@19940731.xyz>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ddab1f10a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/device-link/src/allowlist.ts
Comment thread packages/device-link/src/topics.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@qsoyq 👋 这个 PR 还有 2 条 review conversation 没 resolve(packages/device-link/src/allowlist.ts / packages/device-link/src/topics.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) labels Aug 25, 2026
Signed-off-by: qsoyq <github@19940731.xyz>
@MagicLizi MagicLizi removed the awaiting-discussion 等待维护者讨论(review-pr) label Aug 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf8c5b3695

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-host/index.ts Outdated
Signed-off-by: qsoyq <github@19940731.xyz>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7c46e7e9e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/bootstrap-electron.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径但 description 未附界面效果证据。建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51703a7d12

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/mobile/app/sessions/new.tsx
Signed-off-by: qsoyq <github@19940731.xyz>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75a6d0db5a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/agent-binaries/pi-runtime-recovery.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7ed4d83eb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useAvailableAgents.ts Outdated
Comment thread apps/mobile/app/sessions/new.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73f674aa3a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/mobile/app/sessions/new.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4de0d0e55

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/mobile/app/sessions/new.tsx
Signed-off-by: qsoyq <github@19940731.xyz>
@MagicLizi

Copy link
Copy Markdown
Contributor

这个 PR 需要维护者确认后再继续(产品/跨端可见性 + preload/IPC)。

请维护者直接在本 PR 上 Approve;若要改,请 Request Changes。讨论记录:#3417

@MagicLizi

Copy link
Copy Markdown
Contributor

@qsoyq 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

Signed-off-by: qsoyq <github@19940731.xyz>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 036ebb7b9b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/mobile/app/sessions/new.tsx Outdated
@qsoyq
qsoyq force-pushed the fix-issue-3382-pi-network-recovery branch from ab6a02e to 7465b5d Compare August 26, 2026 07:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7465b5d7fa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useAvailableAgents.ts Outdated
…pi-network-recovery-1

Signed-off-by: qsoyq <github@19940731.xyz>

# Conflicts:
#	packages/maker-core/src/agents/pi/windows-git-path-powershell.test.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@qsoyq 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/hooks/useAvailableAgents.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8c598df09

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useAvailableAgents.ts Outdated
Comment thread apps/mobile/app/sessions/new.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be6464d021

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useAvailableAgents.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@qsoyq 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/hooks/useAvailableAgents.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Signed-off-by: qsoyq <github@19940731.xyz>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14662e854d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useAvailableAgents.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@qsoyq 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/hooks/useAvailableAgents.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi removed the awaiting-discussion 等待维护者讨论(review-pr) label Aug 28, 2026

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve:#3394 离线启动后 Pi 增量恢复与 roster 推送,核对 head 1321b7c8b1fb 与讨论 #3417

代码路径:splash Pi 失败不阻塞其它 agent;恢复走 managed prepare + 幂等 registerAgentmaker:agents:changed 为空 payload 的加法 push,旧被控端不发;Mobile 仍走既有 list。未见 P0/P1。packaged/真机断网路径作者已声明未验,不挡合并。

@MagicLizi
MagicLizi merged commit 870a752 into makecindy:main Aug 28, 2026
10 checks passed
@MagicLizi

Copy link
Copy Markdown
Contributor

离线启动把 Pi 整条链路拖死,这次改成失败只把自己摘掉、网络回来再增量挂回去,桌面和手机的 roster 也能跟着刷新。谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants